package com.jic.member.impl;

import java.lang.Long;
import java.util.List;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.MememberGradeIncrement;
import com.jic.member.mapper.MememberGradeIncrementMapper;
import com.jic.member.service.MememberGradeIncrementService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 会员等级管理-成长值规则主表
 * @author : 
 * @email : 
 * @since : 2020-04-02 07:58:21
 * @version : v1.0.0
 */
@Service
public class MememberGradeIncrementServiceImpl implements MememberGradeIncrementService{

    @Autowired
    private MememberGradeIncrementMapper mememberGradeIncrementMapper;

    @Override
    public long insert(MememberGradeIncrement mememberGradeIncrement) {
        long flag = mememberGradeIncrementMapper.insert(mememberGradeIncrement);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return mememberGradeIncrementMapper.delete(id);
    }

    @Override
    public long update(MememberGradeIncrement mememberGradeIncrement) {
        return mememberGradeIncrementMapper.update(mememberGradeIncrement);
    }

    @Override
    public MememberGradeIncrement queryByPrimaryKey(Long incrementId){
        return mememberGradeIncrementMapper.queryByPrimaryKey(incrementId);
    }

    @Override
    public List<MememberGradeIncrement> query(MememberGradeIncrement mememberGradeIncrement){
        return mememberGradeIncrementMapper.query(mememberGradeIncrement);
    }

    @Override
    public PageResult<MememberGradeIncrement> queryPage(MememberGradeIncrement mememberGradeIncrement, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<MememberGradeIncrement> list = mememberGradeIncrementMapper.queryPage(startIndex, pageQuery.getLimit(), mememberGradeIncrement);
        long count = mememberGradeIncrementMapper.queryPageCount(mememberGradeIncrement);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}